<template>
	<view class="page flex-col">
		<view class="layer2 flex-col">
			<view class="bd3 flex-col ">
				<view class="orderNo">订单号：{{orderNo}}</view>
				<view class="order-line"></view>
				<view class="tx-icon-div">
					<uni-icons v-if="orderStatus == 0" type="spinner-cycle" size="30"></uni-icons>
					<view v-if="orderStatus == 1" class="tx-ok-div">
						<image src="../../static/icon_take_money_succeed.png" class="tx-ok"></image>
						<view class="tx-ok-label">提现成功</view>
					</view>
					<view v-if="orderStatus == 77" class="tx-ok-div">
						<image src="../../static/icon_take_money_succeed.png" class="tx-ok"></image>
						<view class="tx-ok-label">提现失败</view>
					</view>
					<view v-if="orderStatus == 5" class="tx-ok-div">
						<image src="../../static/icon_take_money_fail.png" class="tx-ok"></image>
						<view class="tx-ok-label">提现失败</view>
					</view>
					<view v-if="orderStatus == 2" class="tx-ok-div">
						<image src="../../static/icon_take_money_succeed.png" class="tx-ok"></image>
						<view class="tx-ok-label">兑奖已经提现</view>
					</view>
					<view v-if="orderStatus == 99" class="tx-ok-div">
						<image src="../../static/icon_take_money_fail.png" class="tx-ok"></image>
						<view class="tx-ok-label">提现失败</view>
					</view>
					<view v-if="orderStatus == 98" class="tx-ok-div">
						<image src="../../static/icon_take_money_fail.png" class="tx-ok"></image>
						<view class="tx-ok-label">提现失败</view>
					</view>
					<view v-if="orderStatus == 4" class="tx-ok-div">
						<image src="../../static/icon_take_money_fail.png" class="tx-ok"></image>
						<view class="tx-ok-label">提现失败</view>
					</view>
				</view>
				<view v-if="orderStatus == 0" class="tx-label">
					提现中...
				</view>
				<view v-if="orderStatus == 1" class="tx-label">
					提现成功，稍有延迟请注意查看微信零钱。
					<view class="img-info">
						如下图:
						<image class="price1" src="../../static/price1.jpg"></image>
						<image class="price2" src="../../static/priceinfo.png"></image>
					</view>
				</view>
				<view v-if="orderStatus == 2" class="tx-label">
					兑奖已经提现，稍有延迟请注意查看微信零钱。
					<view class="img-info">
						如下图:
						<image class="price1" src="../../static/price1.jpg"></image>
						<image class="price2" src="../../static/priceinfo.png"></image>
					</view>
				</view>
				<view v-if="orderStatus == 98" class="tx-label">
					提现失败,此微信当天提现已上限,请明天在小程序中领奖
				</view>
				<view v-if="orderStatus == 5" class="tx-label">
					提现失败,请1分钟后重试
				</view>
				
				<view v-if="orderStatus == 99" class="tx-label">
					抱歉，提现失败(余额不足),请联系客服。
				</view>
				<view v-if="orderStatus == 4" class="tx-label" @click="callKh()">
					提现失败,请咨询客服:<a class="contact-span" >{{kfPhone}}</a>
				</view>
				<view v-if="orderStatus == 77" class="tx-label">
					恭喜您，中大奖，请联系客服领取奖金
				</view>
			</view>
			<view class="contact-server" @click="callKh()">提现如有任何问题，请咨询客服电话：<a class="contact-span" >{{kfPhone}}</a></view>
		</view>
	</view>
</template>

<script>
	import urlConfig from '../../common/config.js'
	export default {
		data() {
			return {
				orderNo:'',
				orderStatus:0,
				kfPhone:'',
				orderNo:'',
			}
		},
		created() {
			
		},
		onLoad(option){
			if(option.orderNo){
				this.orderNo = option.orderNo;
			}
			if(option.kf){
				this.kfPhone = option.kf;
			}
			let devNo = decodeURIComponent(option.q);
			console.log(devNo)
			if(devNo && devNo != 'undefined'){
				console.log(devNo)
				// if(devNo.indexOf("orderNo=") > -1){
				// 	this.orderNo = devNo.slice(devNo.indexOf("orderNo=")+8);
				// }
				let no = this.getUrlParams(devNo,'orderNo');
				if(no){
					this.orderNo = no
				}
				this.kfPhone = this.getUrlParams(devNo,'kf');
			}
			let that = this;
			uni.login({
				success: loginRes => {
					console.log(loginRes)
					that.code = loginRes.code
					that.$api.miniCodeLoginAddTx({orderNo:this.orderNo,code:loginRes.code}).then(res =>{
						this.orderStatus = 1;
					}).catch(res =>{
						console.log(res)
						this.orderStatus = res.code;
					});
				}
			})
		},
		methods: {
			callKh(){
				uni.makePhoneCall({
					phoneNumber: urlConfig.kfPhone
				});
			},
			getUrlParams(url,key) {
			    // 通过 ? 分割获取后面的参数字符串
			    let urlStr = url.split('?')[1]
			    // 创建空对象存储参数
				let obj = {};
			    // 再通过 & 将每一个参数单独分割出来
				let paramsArr = urlStr.split('&')
				for(let i = 0,len = paramsArr.length;i < len;i++){
			        // 再通过 = 将每一个参数分割为 key:value 的形式
					let arr = paramsArr[i].split('=')
					obj[arr[0]] = arr[1];
				}
				return obj[key]
			}
		}
	}
</script>

<style>

@import './common.css';
@import './index.css';
.contact-server{
	text-align: center;
	color: #333;
	font-size: 36rpx;
	margin-top: 30rpx;
	font-weight: bold;
}
.contact-span{
	color: #ff0000;
}
.price1{
	width: 472rpx;
	height: 92rpx;
	z-index: 9999;
}
.price2{
	width: 472rpx;
	height: 497rpx;
	z-index: 9999;
}
.img-info{
	display: flex;
	flex-direction: column;
}
</style>
